home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DLLCust_Files / BIASAXON / BKADJSIG.C < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.6 KB  |  52 lines

  1. // Dynamic link library implementation of BackSigmoidAxon with adaptible slope
  2.  
  3. #include "NSDLL.h" 
  4.  
  5. /********************************/
  6. /* Backpropagation of component */
  7.  
  8. __declspec(dllexport) void performBackBiasAxon(
  9.     DLLData    *instance,        // Pointer to instance data
  10.     DLLData    *dualInstance,    // Pointer to the forward axons instance data
  11.     NSFloat    *data,             // Pointer to the layer of processing elements (PEs)
  12.     int     rows,            // Number of rows of PEs in the layer
  13.     int     cols,            // Number of columns of PEs in the layer
  14.     NSFloat    *error,         // Pointer to the sensitivity vector
  15.     NSFloat    *gradient         // Pointer to the bias gradient vector
  16.     )
  17.     
  18. {
  19.     int i,length=rows*cols;
  20.     NSFloat *beta = getWeights(dualInstance);
  21.     NSFloat *betaGradient = getWeights(instance);
  22.  
  23.     for (i=0; i<length; i++) {
  24.         error[i] *= beta[i]*(data[i]*(1.0f-data[i]) + 0.1f);
  25.         if (gradient)
  26.             gradient[i] += error[i];
  27.         if (betaGradient)
  28.             betaGradient[i] += error[i]*data[i];
  29.     }
  30. }
  31.  
  32. /******************************************/
  33. /* Management of instance data (OPTIONAL) */
  34.  
  35. __declspec(dllexport) DLLData *allocBackBiasAxon(
  36.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  37.     DLLData    *dualInstance,    // Pointer to forward axonÆs instance data (may be NULL)
  38.     int     rows,            // Number of rows of PEs in the layer
  39.     int     cols            // Number of columns of PEs in the layer
  40.     )
  41. {
  42.     DLLData *instance = allocDLLInstance(oldInstance);
  43.     setWeights(instance, rows*cols);
  44.     return instance;
  45. }
  46.  
  47. __declspec(dllexport) void freeBackBiasAxon(DLLData *instance)
  48. {
  49.     freeDLLInstance(instance);
  50. }
  51.  
  52.